#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Purpose: Test project editor dialog
# Created: 02/04/2009
# $Id $
# Copyright (c) 2008,2009 by University College London
# Authors:
# Didrik Pinte --<dpinte@dipole-consulting.com>
#
# This program is free software under the GPL (>=v2)
# Read the file COPYING coming with HydroPlatform for details.

import unittest
import wxversion
wxversion.select("2.8")
import wx

import support
support.init_hydroplatform()

from hydroplatform.model.network import Project
from hydroplatform.model.units import UnitCategory
from hydroplatform.ui.projecteditordialog import TraitedProjectEditorDialog, \
     ProjectHandler

class TestProjectEditorDialog(unittest.TestCase):
    
    def test_traitdialog(self):
        g1 = UnitCategory(name="Length", 
                          selected_units = [' m'],
                          available_units=[' m',' km',' cm',' miles', ' ft'])        
        g3 = UnitCategory(name="Area", available_units=['kWh','J','cal'])
        g4 = UnitCategory(name="Volume", available_units=['kWh','J','cal'])
        g5 = UnitCategory(name="Flow", available_units=['kWh','J','cal'])
        g2 = UnitCategory(name="Energy", available_units=['kWh','J','cal'])
        g6 = UnitCategory(name="Monetary", available_units=['kWh','J','cal'])
        session = support.get_dbsession()
        support.load_sample_network1(session)
        project = session.query(Project).first()
        context = support.Context()
        context.mainwindow = None
        a = TraitedProjectEditorDialog(project=project,
                                       context=context, 
                                       punits=[g1,g3, g4, g5, g2, g6])
        a.configure_traits(kind="modal", handler=ProjectHandler())

if __name__=='__main__':
    unittest.main()